Skip to content

Pi accounts: ask a login's own questions on the phone - #201

Merged
deymosh merged 3 commits into
masterfrom
feat/pi-phone-credentials
Nov 18, 2026
Merged

deymosh merged 3 commits into
masterfrom
feat/pi-phone-credentials

Conversation

@deymosh

@deymosh deymosh commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Pi accounts from the phone: Pi's login questions on the connect form, so the subscription sign-ins and multi-field key logins work. Also the owed bug hunt of #200, with its one real finding fixed.

What was checked first

The phone already drives Pi accounts through the generic "AI providers → Connect a provider" page, since the Pi driver reports supports.accounts. Verified live through the built host with real Pi 1.5.2 and the fake model: a key stored with account-action lands in Pi's auth.json, the provider's models appear, a turn on that provider sends exactly that key (the fake model refuses any other), and removing it clears the models.

What was missing: Pi asks a login's questions as it goes, while the phone needs them as the method's fields up front. The driver offered none and cancelled any prompt besides the key or a pasted address. So these all failed from the phone:

  • the Anthropic (Claude Pro/Max), OpenAI Codex (ChatGPT) and Radius sign-ins, which start with a choice of how;
  • Copilot, which asks a GitHub Enterprise domain first;
  • the Cloudflare key logins, which ask account and gateway IDs;
  • Bedrock and Vertex, which ask for a method first.

Commits

  1. fix(agent-host): keep session credentials out of what Pi reports on failure. From the bug hunt of fix(agent-host): keep the Pi provider token out of the model's processes #200. Pi's stderr (logged, and the ended reason sent to the phone), a provider's error reply (the turn's error entry) and the retry status line went out unredacted. An endpoint that echoes the header it refused would leak the profile token. Claude and OpenCode already redact. The retry line is now redacted before its 120-character cut. Failing-first test, also proven against the cut order reversed.
  2. feat(agent-host): ask a Pi login's own questions on the phone. The helper's full listing runs every login through Pi's own ModelRuntime.login against a scratch auth.json, with fetch, sockets, listening and child processes blocked, following every option of each choice. The driver turns the paths into fields keyed by Pi's question: choices restricted to options that work from a phone, a single workable option auto-answered, when for questions behind a choice, and a method with no workable path not offered. A login re-reads its provider's questions, validates the phone's answers, and answers Pi's prompts once each.
  3. docs: docs/PI.md: what the form asks and how it is found; the page's real name.

No wire or phone change: AccountMethod.fields, answers and the connect form's field rendering already exist (OpenCode uses them).

Bug hunt of #200 (git diff 2c2dd3c 1592fab)

  • Unredacted failure text: real, fixed in commit 1.
  • CODEDECK_PI_PROVIDER_TOKEN no longer scrubbed from the inherited env: not real. Nothing reads it any more, so an inherited copy is like any other inherited variable, which the driver passes on by design.
  • The fake model's --key on its argv: not real. It's a separate test process that no leak assertion inspects.
  • The escaping (configLiteral) matches Pi's resolver, and fd 3 without a pipe throws EBADF, which is caught.

Review of this PR (bug hunt during CI)

  • Real, folded into commit 1: three more paths where Pi's raw failure text reached the log. These were extension_error, a dialog error, and an unreadable stdout line, whose reason was V8's JSON.parse message: it quotes the line's start, cut where redaction can't find it. The decoder now passes a fixed reason; the line itself goes whole and redacted. Test proven by restoring the parser's message.
  • Not changed: keys Pi inherits from the machine's own environment aren't redacted. That's the same params-only convention as the Claude and OpenCode drivers, since the bridge didn't hand them over.
  • Accounts: each Pi 1.5.2 login implementation was checked against the fields offered, with no mismatch found. Conditional when fields have no Pi provider using them yet.

Verification

  • ./codedeck check --changed: host install, typecheck, test, build; android bindings and gradle (unit, Paparazzi, lint) all ok.
  • New real-Pi tests fail on master's code. Live through the built host:
    • the listing shows Cloudflare's IDs, the Anthropic/Codex/Radius choices and Copilot's optional domain, in about 1 s for 43 providers;
    • a Cloudflare key is refused without its account ID and stored with CLOUDFLARE_ACCOUNT_ID with it;
    • an Anthropic sign-in on "copy code" returned Pi's page, then cancelled.
  • Not verified: a completed real sign-in (needs a real account), or the form on a device.

Traffic

None added on the wire. Opening the provider picker costs the bridge about 1 s more of local work.

🤖 Generated with Claude Code

deymosh and others added 3 commits November 18, 2026 22:04
…ailure

A Pi session's failure text reaches the bridge log and the phone: Pi's
stderr (logged, and the reason in the session's `ended` frame), the error
a provider sent back (the turn's error entry) and its first line on each
retry status. An endpoint that echoes the header it refused puts the
provider profile's token there. The Claude and OpenCode drivers already
pass such text through redactSecrets; the Pi driver did not.

Every such text now goes through the session's credentials (the profile
token, and the credential and environment values the bridge handed over)
before it is logged or shown, and so does the rest of what Pi says that
the log keeps: an extension's failure, a dialog that could not be
answered, a line on Pi's stdout that is not a record. For such a line the
decoder no longer passes on the JSON parser's message, which quotes the
line's first characters cut where a secret could no longer be found; the
line itself is logged whole, redacted. A retry line is redacted before it is cut
to its first 120 characters, since a token cut in half is no longer
found. The test places the token across that cut, and fails when the
order is reversed.

Co-Authored-By: Claude Code <[email protected]>
Pi asks a login's questions as it goes: Cloudflare's account and gateway
IDs after the key, how to sign in to Anthropic or OpenAI Codex (a page or
a code), Radius's browser or device code, a GitHub Enterprise domain
before Copilot's device code. The phone's account form asks a method's
fields before it starts, and the Pi driver offered none, so it cancelled
every such login: the Claude Pro/Max, ChatGPT (Codex), Copilot and Radius
sign-ins and those key logins all failed from the phone.

The account helper's listing now finds those questions by running each
provider's login through Pi's own ModelRuntime.login with every way off
the machine blocked (fetch, sockets, listening, child processes),
placeholder answers, and a scratch auth.json deleted afterwards. A login
is followed down each option of every choice it offers. The driver turns
the paths into the method's fields, keyed by Pi's own question:

- a key login works on a path with exactly one secret (the phone's key)
  that finishes without sending the user anywhere; a sign-in works on a
  path with no secret that ends at a page or a code;
- a choice offers only the options that lead to a working path, and with
  one such option it is answered without asking (Amazon Bedrock's bearer
  token, Google Vertex's API key);
- a question asked only after a choice carries that choice as its `when`;
- a method with no working path is not offered (Pi's own ChatGPT sign-in
  under OpenAI fails without a device id).

A key or a sign-in reads that provider's questions again, checks the
phone's answers (a required one missing, a choice not offered) and
answers Pi's prompts from them, once each; a question the listing did not
find is still refused with Pi's words. Listing every provider with its
questions takes about a second; a connected-only listing does not look.

Verified live through the built host on Pi 1.5.2: the listing shows the
fields above, a Cloudflare key is refused without its account ID and
stored with CLOUDFLARE_ACCOUNT_ID with it, and the Anthropic sign-in
started on "copy code" returned Pi's page, then cancelled. A key stored
through account-action was the one a turn sent (the fake model refuses
any other key).

Co-Authored-By: Claude Code <[email protected]>
docs/PI.md named the phone's page "Accounts" (it is the agent's AI
providers page, "Connect a provider") and said a login that asks more
than a key is refused. It now says which questions the form shows, how
the bridge finds them without anything leaving the machine, and which
ways of a login need the machine's own /login.

Co-Authored-By: Claude Code <[email protected]>
@deymosh
deymosh force-pushed the feat/pi-phone-credentials branch from cb3ebba to f44327c Compare November 18, 2026 21:04
@deymosh
deymosh merged commit 4490a23 into master Nov 18, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant